local jianzhi = fk.CreateSkill{
    name = "jin_heg__jianzhi",
}

Fk:loadTranslationTable{
    ["jin_heg__jianzhi"] = "奸志",
    [":jin_heg__jianzhi"] = "当你造成致命伤害时，你可弃置所有手牌，令本回合下次所有角色执行的奖惩改为三倍。",
     ["#jin_heg__jianzhi-invoke"] = "奸志：是否弃置所有手牌，令本回合下次击杀奖励改为三倍？",

    ["$jin_heg__jianzhi1"] = "怀志拥权，谁敢不服？",
    ["$jin_heg__jianzhi2"] = "天下凶凶，由我一人。",
}

jianzhi:addEffect(fk.DamageCaused, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(jianzhi.name) and
      data.damage >= (data.to.hp + data.to.shield) and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if not table.find(player:getCardIds("h"), function (id)
        return not player:prohibitDiscard(id)
      end) then
      room:askToCards(player, {
        min_num = 1,
        max_num = 1,
        include_equip = false,
        skill_name = jianzhi.name,
        pattern = "false",
        prompt = "#jin_heg__jianzhi-invoke",
        cancelable = true,
      })
      return
    end
    return room:askToSkillInvoke(player, {
      skill_name = jianzhi.name,
      prompt = "#jin_heg__jianzhi-invoke",
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:throwAllCards("h", jianzhi.name)
    room:setBanner(jianzhi.name, 1)
    room:setBanner("additional_reward", 2)
  end,
})

local spec = {
  can_refresh = function(self, event, target, player, data)
    return target == player and player.room:getBanner(jianzhi.name)
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    room:setBanner(jianzhi.name, 0)
    room:setBanner("additional_reward", 0)
  end,
}
jianzhi:addEffect(fk.Deathed, spec)
jianzhi:addEffect(fk.TurnEnd, spec)

return jianzhi